#include "GameGlobal.h"
#include "MapSlot.h"

class MapGrid :public CCObject
{
public:
	static const int	OFFSET_X = 110;
	static const int	OFFSET_Y = 30;
	static const int	WIDTH = 780;
	static const int	HEIGHT = 500;
	static const int	SLOT_ROW_COUNT = 5;
	static const int	SLOT_COLUMN_COUNT = 9;
private:
	CCArray* m_arry;
	MapGrid(void);
	~MapGrid(void);

private:
	static MapGrid*		m_sharedMapGrid;

public:	
	static MapGrid*		GetSharedCache();
	static void			ClearSharedCache();
	static CCPoint		GetSlotCoordinate(int row,int cloumn );
	static CCPoint		GetOutRangeCoordinate(int row,int cloumn );
	static CCPoint		GetLeftOutRange();
	static CCPoint		GetRightOutRange();
	static int			GetRowCoordinate(int row);
	static int			GetColumnCoordinate(int column);

	CCRect				Rect();
	CCRect				ExtendRect();
	bool				containsTouchLocation(CCTouch* touch);

	MapSlot*			GetSlotByKey(string key);
	MapSlot*			SlotOverlapped(CCPoint* cp);

	CCPoint				Set2Slot(MapSlot* slot);
	CCPoint				GetSlotCoordinate(MapSlot* slot );
	CCPoint				GetNextSlotCoordinate(MapSlot* slot );
	CCPoint				GetOutRangeCoordinate(MapSlot* slot );

	bool				IsOutOfRange(CCPoint point);

};

